import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:loginapp/widget/particle//particle_widget.dart';
import 'package:simple_animations/simple_animations.dart';
import 'package:supercharged/supercharged.dart';

enum _ColorTween { color1, color2 }

class NewsPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: new Text("欢迎来到微博女厕所"),
      ),
      backgroundColor: Colors.black,
      body: Stack(children: <Widget>[
        Positioned.fill(child: AnimatedBackground()),
        Positioned.fill(child: ParticlesWidget(30)),
        Positioned.fill(
          child: Padding(
              padding: EdgeInsets.fromLTRB(1,270,1,1),
              child:Column(
                children: <Widget>[
                  new Center(
                    child: GestureDetector(
                      onTap: () {
                        Navigator.pushNamed(context, '/Navigation');
                      },
                      child: Text(
                        "进入女厕",
                        style: new TextStyle(
                            fontSize: 20,
                            fontWeight: FontWeight.bold,
                            letterSpacing: 20,
                            // height: 10,
                            color: Colors.white),
                      ),

                    ),
                  ),
                  new Center(
                    child: GestureDetector(
                      onTap: () {
                        Navigator.pushNamed(context, '/main');
                      },
                      child: Text(
                        "返回登录",
                        style: new TextStyle(
                            fontSize: 20,
                            letterSpacing: 20,
                            height: 5,
                            fontWeight: FontWeight.bold,
                            color: Colors.white),
                      ),

                    ),
                  )
                ],
              ))
        ),
      ]),

    );
  }
}

class AnimatedBackground extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final tween = MultiTween<_ColorTween>()
      ..add(
        _ColorTween.color1,
        Color(0xffD38312).tweenTo(Colors.lightBlue.shade900),
        3.seconds,
      )
      ..add(
        _ColorTween.color2,
        Color(0xffA83279).tweenTo(Colors.blue.shade600),
        3.seconds,
      );

    return MirrorAnimation<MultiTweenValues<_ColorTween>>(
      tween: tween,
      duration: tween.duration,
      builder: (context, child, value) {
        return Container(
          decoration: BoxDecoration(
              gradient: LinearGradient(
                  begin: Alignment.topCenter,
                  end: Alignment.bottomCenter,
                  colors: [
                value.get<Color>(_ColorTween.color1),
                value.get<Color>(_ColorTween.color2)
              ])),
        );
      },
    );
  }
}
